<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>记事本</title>
    <link rel="stylesheet" href="./css/index.css">
    <!-- <link rel="stylesheet" href="./css/normalize.css"> -->
</head>

<body>
    <div id="app">
        <header class="header">
            <h1>记事本</h1>
            <input v-model="inputValue" @keyup.enter="add" class="new-todo" autocomplete="off" autofocus="autofocus"
                placeholder="请输入内容" type="text" maxlength="15">
        </header>

        <section class="main">
            <ul class="todo-list">
                <li class="todo" v-for="(item,index) in list">
                    <span>{{index+1}}</span>
                    <label>{{item}}</label>
                    <button @click="remove(index)">X</button>
                </li>
            </ul>
        </section>

        <footer class="footer">
            <span v-if="list.length!=0">{{list.length}} items left</span>
            <a v-show="list.length!=0" href="#" @click="clear">Clear</a>
        </footer>

    </div>

    <script src="./js/flexible.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                list: [],
                inputValue: ""
            },
            methods: {
                add: function () {
                    this.list.push(this.inputValue);
                },
                remove: function (index) {
                    this.list.splice(index, 1)
                },
                clear: function () {
                    this.list = []
                }
            }

        })
    </script>
</body>

</html>